package com.demo.user;

import java.util.Map;

import org.nature.framework.bean.ValidatorFail;
import org.nature.framework.core.NatureMap;
import org.nature.framework.util.ValidatorUtil;
import org.nature.framework.validator.NatureValidator;

public class UserValidator implements NatureValidator{

	public ValidatorFail validate(NatureMap params, Map<String, String> errorMap) {
		String icon = "<i class='glyphicon glyphicon-info-sign'></i>";
		int age = params.getInt("user.age");
		if (age<=0||age>150) {
			errorMap.put("error_age", icon+"年龄范围错误");
		}
		ValidatorUtil.validate(params, errorMap, "user.name", ValidatorUtil.accountRegx, "error_name", icon+"用户名格式错误");
		return ValidatorFail.backTo("oper.ftl");
	}


}
